/*    */ package com.zimbra.cs.service.account;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AccountConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Identity;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.soap.DocumentHandler;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CreateIdentity
/*    */   extends DocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 34 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 35 */     Account account = getRequestedAccount(zsc);
/*    */     
/* 37 */     if (!canModifyOptions(zsc, account)) {
/* 38 */       throw ServiceException.PERM_DENIED("can not modify options");
/*    */     }
/*    */     
/* 41 */     Element identityEl = request.getElement("identity");
/* 42 */     String name = identityEl.getAttribute("name");
/* 43 */     Map<String, Object> attrs = AccountService.getAttrs(identityEl, true, "name");
/*    */     
/* 45 */     Identity identity = Provisioning.getInstance().createIdentity(account, name, attrs);
/*    */     
/* 47 */     Element response = zsc.createElement(AccountConstants.CREATE_IDENTITY_RESPONSE);
/* 48 */     ToXML.encodeIdentity(response, identity);
/* 49 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/account/CreateIdentity.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */